# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: M0Rf30

pkgbase=capstone
pkgname=('capstone' 'python-capstone')
pkgver=4.0.2
pkgrel=7
pkgdesc='Lightweight multi-platform, multi-architecture disassembly framework'
url='https://www.capstone-engine.org/index.html'
arch=('loong64' 'x86_64')
license=('BSD')
makedepends=('glibc' 'python' 'python-setuptools')
options=('staticlibs')
source=(https://github.com/aquynh/capstone/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('7f93534517307b737422a8825b66b2a1f3e1cca2049465d60ab12595940154aaf843ba40ed348fce58de58b990c19a0caef289060eb72898cb008a88c470970e')
b2sums=('435729a8fef2dce6495635352101b3befe563c8404efdbb0dccabecbe2bded332221665bacdbcd9043dda72b652b6f29c0e1a548cefb8c64d5b6b9dc174ed3d9')

build() {
  cd ${pkgbase}-${pkgver}
  CFLAGS+=" ${CPPFLAGS} -ffat-lto-objects"
  make V=1
}

check() {
  cd ${pkgbase}-${pkgver}
  make check
}

package_capstone() {
  depends=('glibc')
  provides=('libcapstone.so')
  cd ${pkgbase}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -Dm 644 docs/README -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE.TXT -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

package_python-capstone() {
  depends=('capstone' 'python')
  cd ${pkgbase}-${pkgver}/bindings/python
  python setup.py install -O1 --root="${pkgdir}" --prefix=/usr
  install -Dm 644 ../../LICENSE.TXT -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
